package com.deductive.service.special.impl;

import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.lang.tree.TreeNodeConfig;
import cn.hutool.core.lang.tree.TreeUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.deductive.domain.special.SpecialSeaport;
import com.deductive.service.special.SpecialSeaportService;
import com.deductive.mapper.special.SpecialSeaportMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 47338
* @description 针对表【special_seaport(港口)】的数据库操作Service实现
* @createDate 2025-09-01 16:33:11
*/
@Service
public class SpecialSeaportServiceImpl extends ServiceImpl<SpecialSeaportMapper, SpecialSeaport>
    implements SpecialSeaportService{


    @Override
    public List<Tree<Object>> listTree() {
        TreeNodeConfig treeNodeConfig = new TreeNodeConfig();
        treeNodeConfig.setIdKey("id");
        treeNodeConfig.setNameKey("name");
        treeNodeConfig.setParentIdKey("parentId");
        List<SpecialSeaport> list = this.list();
        List<Tree<Object>> treeList = TreeUtil.build(list, 0, treeNodeConfig, (specialHospital, tree) -> {
            tree.setId(specialHospital.getId()); // 设置节点ID
            tree.setName(specialHospital.getName()); // 设置节点名称（显示文本）
            tree.setParentId(specialHospital.getParentId());
            tree.putExtra("englishName", specialHospital.getEnglishName());
            tree.putExtra("country", specialHospital.getCountry());
            tree.putExtra("inlandRiverAndCoastalAreas", specialHospital.getInlandRiverAndCoastalAreas());
            tree.putExtra("type", specialHospital.getType());
            tree.putExtra("address", specialHospital.getAddress());
            tree.putExtra("deepDraft", specialHospital.getDeepDraft());
            tree.putExtra("ingth", specialHospital.getIngth());
            tree.putExtra("numberOfBerths", specialHospital.getNumberOfBerths());
            tree.putExtra("berthingCapacity", specialHospital.getBerthingCapacity());
            tree.putExtra("annualThroughPut", specialHospital.getAnnualThroughPut());
            tree.putExtra("statiscalYearOfAnnualThrough", specialHospital.getStatiscalYearOfAnnualThrough());
            tree.putExtra("navigationTimeLimit", specialHospital.getNavigationTimeLimit());
            tree.putExtra("portFunctions", specialHospital.getPortFunctions());
            tree.putExtra("dockSituation", specialHospital.getDockSituation());
            tree.putExtra("meteorology", specialHospital.getMeteorology());
            tree.putExtra("naturalConditions", specialHospital.getNaturalConditions());
            tree.putExtra("waterway", specialHospital.getWaterway());
            tree.putExtra("sailingMethod", specialHospital.getSailingMethod());
            tree.putExtra("thegulf", specialHospital.getThegulf());
            tree.putExtra("facility", specialHospital.getFacility());
            tree.putExtra("useState", specialHospital.getUseState());
            tree.putExtra("source", specialHospital.getSource());
            tree.putExtra("userParty", specialHospital.getUserParty());
            tree.putExtra("other", specialHospital.getOther());
            tree.putExtra("lon", specialHospital.getLon());
            tree.putExtra("lat", specialHospital.getLat());
        });
        return treeList;
    }
}




